package org.ddd.book.book;

import cn.hutool.core.collection.CollectionUtil;
import lombok.extern.slf4j.Slf4j;
import org.ddd.book.domain.IBaseEntity;
import org.ddd.book.domain.book.entity.BookshelfEntity;
import org.ddd.book.domain.book.repository.IBookshelfRepository;
import org.ddd.book.domain.factoty.RepositoryFactory;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class BookshelfService {

    public void removeBookroomAllBookshelf(Long roomId) {
        List<BookshelfEntity> entity = RepositoryFactory.get(IBookshelfRepository.class).bookroomBookshelfList(roomId);
        if (CollectionUtil.isEmpty(entity)) {
            log.info("the library not has bookshelf,roomId = {}", roomId);
            return;
        }
        log.info("begin to remove bookshelf libraryId = {}", roomId);
        entity.forEach(IBaseEntity::remove);
    }

}
